//
//  TeachLeftView.m
//  fitnessmanage
//
//  Created by wujian on 2018/1/16.
//  Copyright © 2018年 zongquankeji. All rights reserved.
//

#import "TeachLeftView.h"

@implementation TeachLeftView

-(id)initWithFrame:(CGRect)frame{
    
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        UIButton *imageView = [[UIButton alloc] init];
        [self addSubview:imageView];
        self.imageView = imageView;
        
        UIImageView *leftImageView = [[UIImageView alloc] init];
        leftImageView.image = [UIImage imageNamed:@"bg_ject"];
        [self addSubview:leftImageView];
        self.leftImageView = leftImageView;
        
        
        UILabel *leftLabel = [[UILabel alloc] init];
        leftLabel.font = MidFont;
        leftLabel.textColor = CSWhiteColor;
        [leftImageView addSubview:leftLabel];
        self.leftLabel = leftLabel;
        
        [self setConstraints];
    }
    
    return self;
}


-(void)setConstraints{
    
    [self.imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.right.bottom.mas_equalTo(self);
    }];
    
    [self.leftImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(self.imageView);
        
        make.right.mas_equalTo(self.imageView.mas_left).offset(-5);
        
        make.left.mas_equalTo(self);
    }];
    
    [self.leftLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(self.leftImageView);
        
        make.left.mas_equalTo(self.leftImageView).offset(3);
    }];
}

-(void)setImageName:(NSString *)imageName{
    
    _imageName = imageName;
    
    [self.imageView setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [self.imageView setImage:[UIImage imageNamed:imageName] forState:UIControlStateHighlighted];
    
    self.leftLabel.text = imageName;
}

@end
